package com.book.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class Result<T>{
    private String code;
    private String msg;
    private T data;

    public Result(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static Result OK(){
        return new Result(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg());
    }

    public static Result FAIL(){
        return new Result(ResultEnum.FAIL.getCode(), ResultEnum.FAIL.getMsg());
    }

    //通用提示
    public static Result respose(ResultEnum resultEnum){
        return new Result(resultEnum.getCode(),resultEnum.getMsg());
    }

}
